package com.ozo.cloud.common.log.event;

import com.ozo.cloud.api.system.dto.SysOperationLogDTO;
import com.ozo.cloud.api.system.feign.SysOperateLogFeignClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;

/**
 * 登录事件监听
 *
 * @author qiangesoft
 * @since 2024-07-11
 */
@Slf4j
@RequiredArgsConstructor
public class OperateLogListener {

    private final SysOperateLogFeignClient sysOperateLogFeignClient;

    @Async
    @EventListener({OperationLogEvent.class})
    public void saveSysLog(OperationLogEvent event) {
        sysOperateLogFeignClient.add((SysOperationLogDTO) event.getSource());
    }

}
